home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Tools for Macintosh
/
Power Tools for Macintosh (SoftBit)(1992).iso
/
Da's
/
A-B
/
Busy orNot
/
BusyorNot.Pas
< prev
Wrap
Pascal/Delphi Source File
|
1988-01-23
|
6KB
|
199 lines
program BusyorNot;
{$R BusyorNot.Rsrc}
{$D pasdeskacc}
{$U-}
uses MemTypes,QuickDraw,OSIntf,ToolIntf,PackIntf;
const
dCtlEnable = $0400;
type
EventRecP = ^EventRecord;
procedure Open(var Device: DCtlEntry); forward;
procedure Control(var Device: DCtlEntry; Param: LongInt; Code: Integer); forward;
procedure Close(var Device: DCtlEntry); forward;
Procedure Modal(var Number : Str255;var Done : Boolean ;var Device:DCtlEntry);
const
numItems = 5;
OKBtn = 1;
CancelBtn = 2;
TextItem = 3;
btnOff = 0;
btnOn = 1;
noWrap = -1;
var
theDialog : DialogPtr;
itemHit,theType,Ref : Integer;
theTextHdl, theOkHdl, itemHdl : handle;
txtBox, OKbox, itemBox : Rect;
iBeamHdl : CursHandle;
theDlogPeek : DialogPeek;
teHdl : teHandle;
APort : GrafPtr;
begin
with Device do
Begin
Ref := $C000 - 32 * (dCtlRefNum+1);
GetPort(APort);
Number := '';
FlushEvents (everyEvent, 0);
theDialog := GetNewDialog (Ref, nil, pointer (-1));
GetDItem (theDialog, textItem, theType,theTextHdl, txtBox);
SetIText (theTextHdl,'X-XXX-XXX-XXXX');
theDlogPeek := DialogPeek (theDialog);
theDlogPeek^.textH^^.crOnly := noWrap;
SetPort (theDialog);
ShowWindow (theDialog);
Repeat
ModalDialog (Nil,itemHit);
GetDItem (theDialog, itemHit, theType, itemHdl, itemBox);
Until itemHit in [OKBtn,CancelBtn];
if itemHit = CancelBtn then Done:=True;
GetIText (theTextHdl,Number);
SetPort(APort);
DisposDialog(theDialog);
end;
end;
Procedure Modal2(var Hang : Boolean;var Device:DCtlEntry);
const
numItems = 3;
HangBtn = 1;
StayBtn = 2;
btnOff = 0;
btnOn = 1;
var
theDialog : DialogPtr;
itemHit,theType,Ref : Integer;
theOkHdl, itemHdl : handle;
OKbox, itemBox : Rect;
theDlogPeek : DialogPeek;
APort : GrafPtr;
begin
with Device do
Begin
Ref := $C000 - 32 * (dCtlRefNum+1) + 1;
GetPort(APort);
Hang := True;
FlushEvents (everyEvent, 0);
theDialog := GetNewDialog (Ref, nil, pointer (-1));
theDlogPeek := DialogPeek (theDialog);
SetPort (theDialog);
ShowWindow (theDialog);
Repeat
ModalDialog (Nil,itemHit);
GetDItem (theDialog, itemHit, theType, itemHdl, itemBox);
Until itemHit in [HangBtn,StayBtn];
if itemHit = StayBtn then Hang := False;
SetPort(APort);
DisposDialog(theDialog);
end;
end;
procedure Open;
var
InRef,OutRef : Integer;
Done,Yes,Hang : Boolean;
Number,Some,Outst : Str255;
InBuffer,OutBuffer,Move : Ptr;
errCode,Temp,Count,I : Longint;
begin
with Device do
if dCtlwindow = nil then
begin
dCtlFlags := dCtlFlags or dCtlEnable;
Done := False;
Modal(Number,Done,Device);
If not Done then
Begin
InBuffer := NewPtr(25);
OutBuffer := NewPtr(20);
errCode := OpenDriver('.AIn', InRef);
errCode := OpenDriver('.AOut',OutRef);
errCode := SerReset(InRef,19550);
errCode := SerReset(OutRef,19550);
errCode := SerSetBuf(InRef,InBuffer,20);
Some := '';
Outst := 'ATL S7=20 S9=10 ' + Chr(13);
Count := Length(Outst);
For I := 0 to Count - 1 do
Begin
Move := Ptr(Ord(OutBuffer)+I);
Move^ := Byte(Outst[I+1]);
End;
errCode := FSWrite(OutRef,Count,OutBuffer);
For Temp:= 1 to 10 * Maxint do;
InBuffer := Nil;
DisposPtr(InBuffer);
InBuffer := NewPtr(20);
errCode := SerSetBuf(InRef,InBuffer,20);
Outst := 'ATDT ' + Number + Chr(13);
Count := Length(Outst);
For I := 0 to Count - 1 do
Begin
Move := Ptr(Ord(OutBuffer)+I);
Move^ := Byte(Outst[I+1]);
End;
errCode := FSWrite(OutRef,Count,OutBuffer);
For Temp := 1 to 40 * Maxint do;
Count := 20;
errCode := FSRead(InRef,Count,InBuffer);
For I := 0 to (Count - 1) do
Begin
Move := Ptr(Ord(InBuffer)+I);
Some[I] := Chr(Move^);
End;
Yes := (Pos('CO',Some) <> 0);
If Yes then
Begin
sysbeep(10);
Modal2(Hang,Device);
End;
If Hang then
Begin
Count := 1;
Move := Ptr(Ord(OutBuffer));
Move^ := Byte('+');
errCode := FSWrite(OutRef,Count,OutBuffer);
For Temp:=1 to 1000 do;
errCode := FSWrite(OutRef,Count,OutBuffer);
For Temp:=1 to 1000 do;
errCode := FSWrite(OutRef,Count,OutBuffer);
For Temp:= 1 to 10 * Maxint do;
Outst := 'ATH' + Chr(13);
Count := Length(Outst);
For I := 0 to Count - 1 do
Begin
Move := Ptr(Ord(OutBuffer)+I);
Move^ := Byte(Outst[I+1]);
End;
errCode := FSWrite(OutRef,Count,OutBuffer);
End;
end;
end;
end;
procedure Control;
begin
end;
procedure Close;
begin
end;
begin
end.